<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- tab上的图标和标题 -->
	<link rel="icon" href="view/ico/company.ico">
    <title> *公司名称* - 虚拟公司</title>
	<!-- Bootstrap核心CSS以及主题 -->
    <link rel="stylesheet" type="text/css" href="view/css/bootstrap.min.css" />
    <link rel="stylesheet" href="view/css/bootstrap-theme.min.css">
    <!-- Dashboard格式化的CSS -->
    <link rel="stylesheet" type="text/css" href="view/css/dashboard.css" />
    <!-- 加载js相关库 -->
    <script src="view/js/jquery-1.11.1.min.js"></script>
    <script src="view/js/bootstrap.min.js"></script>
	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
	<!--[if lt IE 9]>
	  <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
	  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
	<!-- Ajax用来与后台直接交互 -->
	<script type="text/javascript">
	$(function(){
	   $("#product-trigger").click(function(){
	   		$("#product-modal-body").load("getproductupdate.php");
	   });
	});
    
    $(function(){
       $("#rawmaterial-trigger").click(function(){
               $("#rawmaterial-modal-body").load("getrawmaterialupdate.php");
       });
    });
 
    $(function(){
       $("#loan-trigger").click(function(){
               $("#loan-modal-body").load("getloanupdate.php");
               $("#loanapplication-modal-body").load("loanapplication.php");
       });
    }); 

	$(function(){
	   $("#order-trigger").click(function(){
	   		$("#order-modal-body").load("getorderupdate.php");
	   });
	});
    
    $(function(){
       $("#purchasebuilding-trigger").click(function(){
               $("#building-modal-body").load("getbuildingupdate.php");
       });
    });

	</script>
</head>
<body>
	<!-- 顶部导航栏 -->
	<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
	  <div class="container-fluid">
	  	<!-- 公司名称以及口号 -->
	    <div class="navbar-header">
	      <a class="navbar-brand">
	      <span class="glyphicon glyphicon-home" aria-hidden="true"></span>
	      <?php echo $companyinfo['company_name']; ?>
	      </a>
	      <p class="navbar-text">
	      <?php echo '<a href = "dashboard.php">进入旧版界面</a><br/>';  ?>
	      </p>
	    </div>
		<!-- 顶部菜单 -->
	    <div id="navbar" class="navbar-collapse collapse">
	      <ul class="nav navbar-nav navbar-right">
	        <li><a href="#">设置</a></li>
	        <li><a href="#">公司资料</a></li>
	        <li><a href="#">帮助</a></li>
	      </ul>
	    </div>
	  </div>
	</nav>
	<div class="container-fluid">
		<div class="row">
			<!-- 侧边栏 -->
			<div class="col-sm-3 col-md-2 sidebar">
				<ul class="nav nav-sidebar">
				<li class="active">
				<a href="#"> 
				<span class="glyphicon glyphicon-dashboard" aria-hidden="true"></span><br>
				仪表盘</a>
				</li>
				<li>
				<a href="#"> 
				<span class="glyphicon glyphicon-edit" aria-hidden="true"></span><br/>
				会计记账</a>
				</li>
				<li>
				<a href="#"> 
				<span class="glyphicon glyphicon-list-alt" aria-hidden="true"></span><br/>
				财务报表</a>
				</li>
				<li>
				<a href="#">
				<span class="glyphicon glyphicon-tree-conifer" aria-hidden="true"></span><br/>
				知识结构</a>
				</li>
				<li>
				<a href="#"> 
				<span class="glyphicon glyphicon-cog" aria-hidden="true"></span><br/>
				个人设置</a>
				</li>
				</ul>
			</div>
			<!-- 主体部分 -->
			<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
			<!-- 财年和季度时间轴 -->
			<div class="row card">
				<div class="col-md-1">
					<strong>财年</strong>
					<span class="label label-success">
					<?php echo $companyinfo['company_y']; ?>
					</span>
				</div>
				<div class="col-md-11">
					<div class="progress">
                      <?php  
					  echo '
                      <div class="progress-bar" role="progressbar" aria-valuenow="' 
                      . $companyinfo['company_q']*25  
                      . '" aria-valuemin="0" aria-valuemax="100" style="width: '
                      .  $companyinfo['company_q']*25  
                      .  '%;">Q ' 
                      .  $companyinfo['company_q'];  
                      ?>
					  </div>
				</div>
			</div>
			</div>
			<!-- 成品库存，原材料库存，现金，贷款等信息 -->
			<div class="row card">
               <div class="col-md-3">
                <span class="text-muted">订单</span>
                <br>
                <!-- 按键触发一个新页面 -->
                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#order" id="order-trigger">
                <span class="statistics-count" id='totalfinishedgood'>
                <?php echo $totalordervolume;?>
                </span>
                </button>
              </div>
              <!-- Modal操作界面主体 -->
              <div class="modal fade" id="order" tabindex="-1" role="dialog" aria-labelledby="myOrderModal" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                      </button>
                      <h4 class="modal-title">订单详情</h4>
                    </div>
                    <div class="modal-body" id="order-modal-body">
                    </div>
                    <!-- 显示相关通知 -->
                    <div id="delivermsg"></div>
                  </div>
                </div>
              </div>
            
            
			  <div class="col-md-3">
				<span class="text-muted">成品库存</span>
				<br>
				<!-- 按键触发一个新页面 -->
				<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#product" id="product-trigger">
				<span class="statistics-count" id='totalfinishedgood'>
				<?php echo $numoffinishedgood;?>
				</span>
				</button>
			  </div>
			  <!-- Modal操作界面主体 -->
			  <div class="modal fade" id="product" tabindex="-1" role="dialog" aria-labelledby="myProductModal" aria-hidden="true">
			    <div class="modal-dialog modal-lg">
			      <div class="modal-content">
			        <div class="modal-header">
			          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
			          <span aria-hidden="true">&times;</span>
			          </button>
			          <h4 class="modal-title">产品库存</h4>
			        </div>
			        <div class="modal-body" id="product-modal-body">
			        </div>
			        <!-- 显示相关通知 -->
			        <div id="selltothemarketmsg"></div>
			      </div>
			    </div>
			  </div>

			  <div class="col-md-3 placeholder">
			    <span class="text-muted">原材料库存</span><br>
                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#rawmaterial" id="rawmaterial-trigger">
			    <span class="statistics-count"><?php echo $numofrawmaterialinstock;?></span>
                </button>
			  </div>
              <!-- Modal操作界面主体 -->
              <div class="modal fade" id="rawmaterial" tabindex="-1" role="dialog" aria-labelledby="myRawmaterialModal" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                      </button>
                      <h4 class="modal-title">原材料库存</h4>
                    </div>
                    <div class="modal-body" id="rawmaterial-modal-body">
                    </div>
                    <!-- 显示相关通知 -->
                    <div id="purchaserawmaterialmsg"></div>
                  </div>
                </div>
              </div>              
              
              
              
			  <div class="col-md-3 placeholder">
			    <span class="text-muted">现金</span><br>
			    <span class="statistics-count" id="totalcashequivalent"><?php echo $totalcashequivalent;?></span>
			  </div>
              
              <div class="col-md-3 placeholder">
                <span class="text-muted">贷款</span><br>
                <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#loan" id="loan-trigger">
                <span class="statistics-count" id="totalloan"><?php echo $totalloan;?></span>
                </button>
              </div>
              <!-- Modal操作界面主体 -->
              <div class="modal fade" id="loan" tabindex="-1" role="dialog" aria-labelledby="myLoanModal" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                      </button>
                      <h4 class="modal-title">贷款明细</h4>
                    </div>
                    <div class="modal-body" id="loan-modal-body">
                    </div>
                    <div class="modal-body" id="loanapplication-modal-body">
                    </div>
                    <!-- 显示相关通知 -->
                    <div id="applyforloanmsg"></div>
                  </div>
                </div>
              </div> 
			</div>
			<div class="row">
				<div class="col-md-4 card">
                    <span>经营日志</span>
                    <ul>
                    <?php foreach($actionlog as $k=>$v){
                            echo '<li>第' . $v['action_log_y'] . '财年，第' .$v['action_log_q']   . '季度：' . $v['action_log_content'] .'</li>';
                            } ?>
                    </ul>
				</div>
				<div class="col-md-8 card">
					<span>厂房信息</span>
					<div data-example-id="togglable-tabs" role="tabpanel" class="bs-example bs-example-tabs">
					    <ul role="tablist" class="nav nav-tabs" id="myTab">
					       <?php
                           $i = 1;
                           foreach($buildinginfo as $k=>$v){
                                $buildingtagid = $v['building_tagid'];
                                $elementinfo = $company->getelementinfo($v['building_tagid'], 'building');
                                $buildingname = $elementinfo['element_name'];
                                if($v['construct_period'] ==  0){
                                       $buildingstatus = 1;
                                }else{
                                       $buildingstatus = 0;
                                }
                           
                                echo ' <li class="';
                                if($i==1){
                                    echo 'active';
                                }                               
                                echo  '" role="presentation"><a aria-expanded="true" aria-controls="' . $buildingtagid . '" data-toggle="tab" role="tab" id="' . $buildingtagid . '-tab" href="#' . $buildingtagid . '">
                                <span class="label label-success">' . $buildingname . '</span>
                                </a></li>';                                 
                                $i++;
                            }
                           ?>
                           <!-- 加号代表增加相应的厂房 -->
							<li role="presentation">
							<button type="button" class="btn btn-primary btn-sm" data-toggle="modal"  data-target="#purchasebuilding" id="purchasebuilding-trigger">
							  <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
							</button>
							</li>
                        </ul>
                            <!-- Modal操作界面主体 -->
                            <div class="modal fade" id="purchasebuilding" tabindex="-1" role="dialog" aria-labelledby="mybuildingModal" aria-hidden="true">
                              <div class="modal-dialog modal-lg">
                                <div class="modal-content">
                                 <div class="modal-header">
                                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                 <span aria-hidden="true">&times;</span>
                                 </button>
                                 <h4 class="modal-title">可供选择的厂房</h4>
                                 </div>
                                <div class="modal-body" id="building-modal-body">
                               </div>
                               <!-- 显示相关通知 -->
                               <div id="purchasebuildingmsg"></div>
                              </div>
                             </div>
                            </div>
                            
					    
					    <div class="tab-content" id="myTabContent">
                           <?php
                           foreach($buildinginfo as $k=>$v){
                                $buildingtagid = $v['building_tagid'];
                                $elementinfo = $company->getelementinfo($v['building_tagid'], 'building');
                                $buildingname = $elementinfo['element_name'];
                                $numofpositions = $elementinfo['building_size'];
                                if($v['construct_period'] ==  0){
                                       $buildingstatus = 1;
                                }else{
                                       $buildingstatus = 0;
                                } 
                                echo '<div aria-labelledby="'  . $buildingtagid .  '-tab" id="' . $buildingtagid . '" class="tab-pane fade in active" role="tabpanel">
                                   <table class="table table-striped table-bordered table-hover table-condensed">
                                  <thead>
                                    <tr>
                                      <th>生产线位置</th>
                                      <th>类型</th>
                                      <th>状态</th>
                                      <th>工作状态</th>
                                    </tr>
                                  </thead>
                                  <tbody>';
                                  
                                  for ($i = 1; $i <= $numofpositions; $i++){
                                            echo '<tr><td>位置' . $i . '</td>';
                                            $equipmentinfo = $company->getequipment($v['building_tagid'], $i);
                                            if(!empty($equipmentinfo)){
                                                 $elementinfo = $company->getelementinfo($equipmentinfo['equipment_tagid'], 'equipment');
                                                 $equipmentname = $elementinfo['element_name'];
                                                 if($equipmentinfo['installation_period'] ==  0){
                                                         $equipmentstatus = '安装完成';
                                                         
                                                         $unfinishedgoodinfo = $company->getunfinishedgood($equipmentinfo['equipment_tagid']);
                                                         if(empty($unfinishedgoodinfo)){
                                                                  $workstatus = '生产线空闲中';
                                                         }else{
                                                                  $elementinfo = $company->getelementinfo($unfinishedgoodinfo['product_tagid'], 'product');
                                                                  $unfinishedgood_name = $elementinfo['element_name'];
                                                                  $produceperiod = $unfinishedgoodinfo['produce_period'];
                                                                  $workstatus = '目前有一个<' . $unfinishedgood_name . '>正在生产，还有' . $produceperiod . '个季度完成生产。'; 
                                                         }           
                                                 }else{
                                                         $equipmentstatus = '正在安装';
                                                 }
                                                 echo '<td>' .  $equipmentname . '</td><td>' . $equipmentstatus . '</td><td>' .  $workstatus . '</td>';
                                                 
                                            }else{
                                                  echo '<td>购买新生产线</td><td></td><td></td>'; 
                                            }
                                            echo '<tr>';
                                  }
                                  echo '</tbody></table></div>';
   
                                
                            }
                            ?>                         
					    </div>
					  </div>
				</div>
			</div>                       
			</div>
			</div>

			</div>

			<footer class="footer">
			<div class="container">
			<p class="text-center">相关链接</p>
			</div>
			</footer>

			<script>
			$(function ()
			{ $(".btn").popover();
			});
			</script>
</body>
</html>
